package com.tt.controller;

import com.tt.mapper.CourseMapper;
import com.tt.pojo.Course;
import com.tt.pojo.Student;
import com.tt.service.CourseService;
import com.tt.service.StudentService;
import com.tt.vo.PageResult;
import com.tt.vo.SySResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/course")
public class CourseController {
    @Autowired
    private CourseService service;
    @GetMapping("list")
    public SySResult getStudentList(PageResult pageResult){
        pageResult = service.getCourseList(pageResult);
        return SySResult.success(pageResult);
    }
    @PostMapping("addCourse")
    public SySResult addCourse(Course course){
        service.addCourse(course);
        return SySResult.success();
    }
    @DeleteMapping("deleteCourseById/{id}")
    public SySResult deleteCourseById(@PathVariable Long id){
        service.deleteCourseById(id);
        return SySResult.success();
    }
    @PutMapping("updateCourseById")
    public SySResult updateCourseById(Course course){
        service.updateCourseById(course);
        return SySResult.success();
    }
}
